package mq.rabbitmq;import org.springframework.amqp.core.AmqpTemplate;import org.springframework.beans.factory.annotation.Autowired;import org.springframework.stereotype.Component;/** * @Date: 2020/6/29 14:29 * @Description: */@Componentpublic class Sender {    @Autowired    private AmqpTemplate rabbitTemplate;    public void send() {//        User user=new User();    //实现Serializable接口//        user.setName("Lucy");//        user.setPassword("123");//        //1、使用JSONObject//        String jsonUser = JSONObject.toJSONString(user);        rabbitTemplate.convertAndSend("queue", "Hello,Rabbit!"); //direct类型        //参数：交换机类型，routingKey，消息        rabbitTemplate.convertAndSend("topicExchange", "topic.message", "Hello,Rabbit!"); //topic类型,//        rabbitTemplate.convertAndSend("fanoutExchange", "", "Hello,Rabbit!"); //fanout类型    }}